<template>
  <el-dialog title="编辑发票信息" :visible="invoiceEdit" @close="dialogClose" width="40%">
    <el-form :model="ruleForm" status-icon :rules="rules" ref="invoiceEdit" label-width="auto" class="demo-ruleForm">
      <!-- <el-form-item label="ID：" prop="id">
          <el-input type="text" v-model="ruleForm.id" disabled></el-input>
      </el-form-item> -->
      <el-form-item label="发票抬头：" prop="fptt">
        <el-input type="text" v-model="ruleForm.fptt"></el-input>
      </el-form-item>
      <el-form-item label="纳税人识别号：" prop="nsrsbh">
        <el-input type="text" v-model="ruleForm.nsrsbh"></el-input>
      </el-form-item>
      <el-form-item label="手机号：" prop="sjh">
        <el-input type="text" v-model="ruleForm.sjh"></el-input>
      </el-form-item>
      <el-form-item label="电子邮箱：" prop="dzyx">
        <el-input type="text" v-model="ruleForm.dzyx"></el-input>
      </el-form-item>
      <el-form-item label="注册公司地址：" prop="zcgsdz">
        <el-input type="text" :rows="4" v-model="ruleForm.zcgsdz">
        </el-input>
      </el-form-item>
      <el-form-item label="开户行：" prop="khh">
        <el-input type="text" v-model="ruleForm.khh"></el-input>
      </el-form-item>
      <el-form-item label="银行账户：" prop="yhzh">
        <el-input type="text" v-model="ruleForm.yhzh"></el-input>
      </el-form-item>
      <el-form-item label="注册公司电话：" prop="zcgsdh">
        <el-input type="text" v-model="ruleForm.zcgsdh"></el-input>
      </el-form-item>
      <el-form-item label="收件人姓名：" prop="sjrxm">
        <el-input type="text" v-model="ruleForm.sjrxm"></el-input>
      </el-form-item>
      <el-form-item label="收件人地址：" prop="sjrdz">
        <el-input type="text" v-model="ruleForm.sjrdz"></el-input>
      </el-form-item>
      <el-form-item label="收件人邮编：" prop="sjryb">
        <el-input type="text" v-model="ruleForm.sjryb"></el-input>
      </el-form-item>
      <el-form-item label="一般纳税人证明：" prop="ybnsrzm">
        <el-input type="text" v-model="ruleForm.ybnsrzm"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm()" class="pull-right margin-l-25">确定
        </el-button>
        <el-button @click="dialogClose" class="pull-right">取消</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>
<script>
import {editInvoice} from '../../api/personalCenter/personalCenter';
export default {
  name: 'invoiceEdit',
  data () {
    return {
      ruleForm: {
        userid:'2',
        username:'11',
        fptt:'',
        nsrsbh:'',
        sjh:'',
        dzyx:'',
        zcgsdz:'',
        khh:'',
        yhzh:'',
        zcgsdh:'',
        sjrxm:'',
        sjrdz:'',
        sjryb:'',
        ybnsrzm:''
      },
      // rules: {
      //   id: [
      //     { required: true, message: '请输入字典ID', trigger: 'blur' }
      //   ],
      //   name: [
      //     { required: true, message: '请输入字典名称', trigger: 'blur' }
      //   ],
      //   value: [
      //     { required: true, message: '请输入字典值', trigger: 'blur' }
      //   ],
      //   sort: [
      //     { required: true, message: '请输入排序权重', trigger: 'blur' }
      //   ],
      //   parentid: [
      //     { required: true, message: '请输入上级ID', trigger: 'blur' }
      //   ],
      // }
    };

  },

  props: {
    invoiceEdit: {
      type: Boolean
    },
    tableData: {
      type: Object
    }
  },
  methods: {

    submitForm () {
      this.$refs.invoiceEdit.validate((valid) => {
        if (valid) {
          editInvoice(this.ruleForm).then((res) => {
            if(res){
              console.log(res.msg);
              this.$emit('dialogClose');
            }
          })
        }
        else {
          return
        }
      });
    },

    dialogClose () {
      this.$emit('dialogClose')
    }
  },
  mounted () {
    this.ruleForm = this.tableData;
  }


}
</script>
<style lang="less" scoped>

</style>